import { CarType, Question, Subject } from "./practice";

// 课程标签 - 列表
export interface CourseTag {
  id: string;
  tagName: string;
  sortNo: number;
}

// 课程
export interface Course {
  id: string;
  knowledgeFrameworkId: number;
  courseName: string;
  courseCoverUrl: string;
  courseDetail: string;
  courseItemType: number;
  isRecommend: boolean;
  /** 是否开启模考 */
  ifContainMockExam: boolean;
  carType: CarType;
  subject: Subject;

  // 绑定的sku
  skuId: string;
  price: number;
  skuPic: string;

  // 已购买
  purchased: boolean;
}

// 课程 - 列表
export interface ListCourse {
  id: string;
  courseName: string;
  courseCoverUrl: string;
  tags: string[];
  isRecommend: boolean;
}

// 课程 - 列表 - 带有价格
export type ListCourseWithPrice = ListCourse & {
  price: number; // 价格
  salesCount: number;
};

// 课程目录
export interface CourseCatalog {
  id: string;
  parentId: string;
  catalogName: string;
  catalogDesc: string;
  catalogStatus: 0 | 1;
}

export enum CourseItemType {
  VIDEO = 1,
  ARTICLE = 2,
  QUESTION = 3,
  LIVE = 4,
  TRAIN = 5,
  EXAM = 6,
}

export enum CourseItemStatus {
  ENABLE = 1,
  DISABLE = 2,
}

export type StudyRecord = {
  studyProgress?: number; // 学习进度
  studyRemark?: string; // 学习备注
  studyScore?: number; // 学习得分
  studyAnswer?: string; // 学习答案
  studyTime?: number; // 学习时长
};

// 课程条目
export interface CourseItem {
  id: string;
  catalogId: string;
  itemName: string;
  itemDesc: string;
  courseItemType: CourseItemType;
  courseItemTypeId: string;
  isFree: boolean; // 是否免费
  itemStatus: CourseItemStatus;
  sortNo: number;
  studyRecord: StudyRecord | null;
}

// 课程视频
export interface CourseVideo {
  id: string;
  videoName: string;
  videoCoverUrl: string;
  videoUrl: string;
  bjyVideoId: number; // 百家云视频id
  aliVideoId: string; // 阿里云视频id
  aliOssUrl: string; // 阿里云视频地址
  videoSize: number; // 视频大小;单位：字节
  videoFormat: string; // 视频格式：video/mp4
  videoDuration: number; // 持续时间，单位秒
  videoDesc: string;
}

// 视频答题
export interface CourseVideoQuestion {
  time: number;
  question: Question;
}

// 课程文章
export interface CourseArticle {
  id: string;
  articleName: string;
  articleCover: string;
  articleContent: string;
}

// 课程文章 - 列表
export interface ListCourseArticle {
  id: string;
  articleName: string;
  articleCover: string;
}

export interface CourseLive {
  id: string;
  liveName: string;
  liveDesc: string;
  liveType: 1 | 2 | 3 | 4;
  roomId: string;
}

export type CourseQuestionSet = {
  id: string;
  carType: CarType;
  subject: Subject;

  /** 已做数量 */
  actionCount: number;
  /** 总题数 */
  totalCount: number;
};

// 课程直播 返回链接
export interface CourseLiveStatus {
  liveStatus: number; // 直播状态 0 回放 1 直播中 -1 未开始
  liveUrl: string; // 直播链接
}

export type CourseItemDetail = null | CourseVideo | CourseArticle | CourseLive | CourseQuestionSet;

export type PlayingInfo = { vid: number; seek: number; videoId: string };
